package com.zyg.apart.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyg.apart.mapper.RectMapper;
import com.zyg.apart.model.Lessee;
import com.zyg.apart.model.Rect;
import com.zyg.apart.service.RectService;
import com.zyg.apart.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class RectServiceImpl implements RectService {

    @Autowired
    private RectMapper rectMapper;

    @Override
    public PageInfo<Map<String, Object>> getAllRect(Integer currentPage) {
        PageHelper.startPage(currentPage, Const.pageSize);
        List<Map<String,Object>> list = rectMapper.getAllRect();
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Map<String, Object> getRectById(Integer id) {
        return rectMapper.getRectById(id);
    }

    @Override
    public int editRect(Rect rect) {
        return rectMapper.editRect(rect);
    }

    @Override
    public int addRect(Rect rect) {
        rect.setR_time(new Date());
        return rectMapper.addRect(rect);
    }

    @Override
    public int delRectById(Integer id) {
        return rectMapper.delRectById(id);
    }
}
